package edu.snake.implement.model.arena;

import edu.snake.core.model.arena.Position;

public class PositionImpl implements Position {
    private final int width;
    private final int height;

    public PositionImpl(int width, int height) {
        synchronized (this) {
            this.width = width;
            this.height = height;
        }
    }

    @Override
    public int getWidth() {
        return width;
    }

    @Override
    public int getHeight() {
        return height;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        PositionImpl that = (PositionImpl) o;

        return height == that.height && width == that.width;

    }

    @Override
    public int hashCode() {
        int result = width;
        result = 31 * result + height;
        return result;
    }

    @Override
    public String toString() {
        return "PositionImpl{" +
                "width=" + width +
                ", height=" + height +
                '}';
    }
}
